package com.dsteiner.xelavos.server.domain;

import java.util.Date;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.dsteiner.widgets.client.ObjectUtil;
import com.dsteiner.widgets.client.domain.ModelObject;
import com.dsteiner.widgets.client.domain.SearchableId;
import com.google.appengine.api.datastore.Blob;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class File extends ModelObject{

	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
    @SearchableId
    private String id;
	
	public String getId(){
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
    @Persistent(defaultFetchGroup="true")
    private Blob blob;

    public File(Blob blob) {
		this.blob = blob;
	}
    
    // Accessors for the fields.  JDO doesn't use these, but your application does.

    public Blob getBlob() {
		return blob;
	}
    public void setBlob(Blob blob) {
		this.blob = blob;
	}

    public boolean equals(Object obj) {
		if (obj == null)
			return false;
		if (!(obj instanceof File))
			return false;
		File other = (File) obj;
		return ObjectUtil.equals(getId(), other.getId());
	}
    
	@Override
	public Date getRegisteredDate() {
		return null;
	}
}